package com.eduadmin.controller;
import com.alibaba.excel.EasyExcel;
import com.eduadmin.entity.Exam;
import com.eduadmin.entity.Statistics;
import com.eduadmin.listener.ExamDataUploadListener;
import com.eduadmin.listener.StatisticsDataUploadListener;
import com.eduadmin.service.IExamService;
import com.eduadmin.service.IStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;

import com.eduadmin.service.IStatisticsService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
 * @author zlc001 统计模块
 **/
// 统计模块控制接口：接受前台的数据，向后台传递参数
@Controller
public class StatisticsController {
    //构造函数自动装配
    private final IStatisticsService statisticsService;
    @Autowired
    public StatisticsController(IStatisticsService statisticsService){
        this.statisticsService = statisticsService;
    }

    //导入统计项目名称
    @RequestMapping(value = "addStatistics")
    @ResponseBody
    public String addStatistics(MultipartFile statisticsinfoFile) throws IOException {
        EasyExcel.read(statisticsinfoFile.getInputStream(), Statistics.class, new StatisticsDataUploadListener(statisticsService)).sheet().doRead();
        return "上传成功";
    }
}
